/**
 * 周计划检测
 */
export const hasWeek = {
	onLoad() {
		this.getWeekPlanArrange()
	},
	methods: {
		getWeekPlanArrange() {
			this.$api.getWeekPlanArrange({
				planDate: this.format(new Date())
			}).then(res => {
				if (res.code) {
					this.$comm.errorToShow('已经存在本周计划')
				}
			})
		},
		format(date) {
			let y = date.getFullYear();
			let m = date.getMonth() + 1;
			let d = date.getDate();
			return y + '-' + this.fill(m) + '-' + this.fill(d);
		},
		fill(a) {
			return 10 > a ? '0' + (0 | a) : a
		}
	}
}
